﻿using Hotel.Application;
using Hotel.Application.Admins.Dto;
using Hotel.Application.Roles.Dto;
using Hotel.Domain;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;

namespace Hotel.Web.Controllers
{
    public class RoleController : BaseController<Role, RoleCreateUpdateDto, RoleListDto>
    {
        private readonly IBaseService<Role, RoleCreateUpdateDto, RoleListDto> service;

        public RoleController(IBaseService<Role, RoleCreateUpdateDto, RoleListDto> service) : base(service)
        {
            this.service = service;
        }

        [HttpGet]
        public async Task<IActionResult> ToPageListAsync(QueryDto dto, int PageSize = 10, int PageIndex = 1)
        {
            Expressionable<Role> exp = new Expressionable<Role>();
            exp.AndIF(!string.IsNullOrWhiteSpace(dto.Keywords), it => it.RoleName.Contains(dto.Keywords));
            var page = await base.PageAsync(exp, PageSize, PageIndex);
            return page;
        }
    }
}
